layui.config({
	dir: '/static/layui/',
	version: false,
	debug: false,
	base: ''
});
var create_tab,
	wait_search,
	om,
	send_info,
	load_data = true,
	create_is_out = false,
	bjd_data_arr = new Array(),
	bjd_return_arr = new Array(),
	bjd_offer_id = 0;
layui.use(['form', 'jquery', 'layer', 'element', 'laydate', 'layim', 'table', 'upload'], function() {
	var form = layui.form;
	var $ = layui.$;
	var layer = layui.layer;
	var element = layui.element;
	var laydate = layui.laydate;
	var layim = layui.layim;
	var table = layui.table;
	var upload = layui.upload;
	if (typeof upload_bjd == "undefined") {
		upload_bjd = ''
	}
	upload.render({
		elem: '#implodeBjd',
		url: upload_bjd,
		acceptMime: 'application/vnd.ms-excel',
		auto: true,
		accept: 'file',
		exts: 'xls',
		multiple: false,
		drag: false,
		before: function(obj) {
			layer.load();
		},
		done: function(res, index, upload) {
			if (res.code == 0) {
				layer.closeAll('loading');
				layer.msg(res.msg);
				return false;
			}
			bjd_data_arr = res.data;
			console.log(bjd_data_arr)
			create_baojiadan_html();
			layer.closeAll('loading');
		},
		error: function(index, upload) {
			layer.msg('网络错误', {
				icon: 2
			});
			layer.closeAll('loading');
		}
	});
	$('#chaxun').on('click', function() {
		let search_order_no = $('#search_order_no').val(),
			post_json = {
				'chk_out_order_no': search_order_no
			};
		send_info(baobendan_url, post_json, function(data) {
			if (data.count == 0) {
				layer.msg('没找到报备单信息');
				$('#search_order_no').val('');
			} else {
				bjd_data_arr = new Array();
				data.data.forEach(function(e, i) {
					bjd_data_arr.push(e.goods_info);
				})
				create_baojiadan_html();
			}
		})

	})
	if (typeof upload_uri == "undefined") {
		upload_uri = ''
	}
	// 上传报价单凭证
	var upload_info = upload.render({
		elem: '.up_baojia_pingzheng',
		url: upload_uri,
		accept: 'file',
		acceptMime: 'image/*,application/pdf',
		exts: 'jpg|png|gif|bmp|jpeg|pdf',
		choose: function() {
			layer.load(1);
		},
		done: function(res) {
			console.log(res.data)
			let view_text = '<span class="invoice-link"><a href="' + res.data.save_path +
				'" style="color: #ffffff;" target="_blank"><i class="layui-icon layui-icon-link"></i>查看凭证</a></span>';

			$('#baojiadan_pingzheng').html(view_text)
			$('#pingzheng').val(res.data.upload_id);
			layer.closeAll('loading');
		},
		error: function() {
			layer.closeAll('loading');
			layer.msg('上传错误', {
				icon: 2,
				anim: 6
			});
			return false;
		}
	});
	//创建报价单
	$('#closeCreateGoods').on('click', function() {
		create_is_out = false;
		$('#create_bjd_select_goods').hide();
		bjd_data_arr = new Array();
		$('.select-bjd-box').html('');
		$('#baojiadan_pingzheng').html('');
		$('#pingzheng').val('');

	})
	create_baojiadan_html = function() {
		if (bjd_data_arr.length > 100) {
			layer.msg('数据不能超过100条');
			bjd_data_arr = new Array();
		}
		var html = '';
		var bjd_sku_arr = new Array();
		var bjd_new_data = new Array();
		bjd_data_arr.forEach(function(e, i) {
			if (bjd_sku_arr.indexOf(e.goods_sku) == -1) {
				bjd_sku_arr.push(e.goods_sku);
				bjd_new_data.push(e);
			}
		})
		bjd_new_data.forEach(function(e, i) {
			var state_text = '未上传';
			bjd_return_arr.forEach(function(e1, i1) {
				// 处理上传结果
				if (e.goods_sku == e1.skuId) {
					state_text = e1.reason;
				}
			})

			if (e.audit_state != 1) {
				layer.msg(e.goods_name + '未审核');
			} else if (!e.sale_state) {
				layer.msg(e.goods_name + '未上架');
			} else {
				var lock_html = ' style="width:60px" ',
					lock_label = '报价';
				lock_dis = '<div style="margin-bottom:6px;">';
				if (e.is_lock == 1 && is_supplier == true) {
					lock_html = 'readonly="readonly" style="width:80px;color:#ff0000"';
					lock_label = '<font style="color:#ff0000;font-weight:bold;">锁定</font>';
					lock_dis =
						'<font style="color:#ff0000;font-weight:bold;">产品已锁定，不可报价，请移除！</font><div style="display:none;">';
				}

				let options = `
				<option value="3" ${e.zhouqi==3?'selected=selected':''}>3天</option>
				<option value="4" ${e.zhouqi==4?'selected=selected':''}>4天</option>
				<option style="display:none;" value="30" ${e.zhouqi==30?'selected=selected':''}>30天</option>
				<option style="display:none;" value="365" ${e.zhouqi==365?'selected=selected':''}>长期追最低</option>
				`;

				let chengbenjia =
					'<span style="width:180px" class="jun_input">库房成本价：<input style="width:60px" type="number" class="chengbenjia-input chengbenjia" data-goods_sku="' +
					e.goods_sku +
					'" name="chengbenjia" data-goods_sku="' +
					e.goods_sku +
					'" value="' + e.chengbenjia + '"/></span>',
					beizhu =
					'<span style="width:140px;" class="jun_input">操作员：<input data-goods_sku="' +
					e.goods_sku +
					'" style="width:60px" type="text" class="beizhu-input beizhus" data-goods_sku="' +
					e.goods_sku +
					'" name="beizhu" value="' + e.beizhu + '"/></span><div data-goods_sku="'+e.goods_sku+'" style="display:none;position: absolute;z-index:9;width:200px;height:100px;right:170px;background:#fff;border:1px solid #dddddd" class="select-ywy"></div>',
					zhouqi =
					'<span style="width:130px" class="jun_input">报价周期：<select data-goods_sku="' +
					e.goods_sku +
					'" name="zhouqi" class="zhouqi zhouqi-input">' + options + '</select></span>',
					kucun = e.view_stock;
				if (is_supplier == true) {
					kucun = 4;
					disabled = 'disabled="disabled"';
				} else {
					disabled = '';
				}
				let zuidijia = '';
				if (typeof(e.zuidijia) != 'undefined') {
					zuidijia = '<span style="width:130px">最低价：' + e.zuidijia + '</span>';
				}
				let xianjia = '（报价范围：' + (e.sale_price * 0.55).toFixed(2) + '~' + (e.sale_price *
					0.99).toFixed(2) + ')'

				let zhenshi = ''
				if (is_supplier == true && supplier_id == 594) {
					let checkbox = ''
					pianyuan_arr.forEach((ee) => {
						checkbox =
							`${checkbox}<label><input name="shengfen_${e.goods_sku}" value="${ee}" type="checkbox" />${ee}</label>`
					})
					zhenshi = `<div style="background:#8291c2">
					地区：<select data-goods_sku="${e.goods_sku}" class="diqu">
						<option value="0">全国</option>
						<option value="1">非偏远地区</option>
						<option value="2">偏远地区</option>
					</select>
					<span class="show-shengfen" style="display:none" data-goods_sku="${e.goods_sku}">
						${checkbox}
					</span>
					真实库存：<input class="zhenshi"  value="" style="width:60px" type="number" data-goods_sku="${e.goods_sku}">
				</div>`
				}

				html = html +
					'<div style="margin-top: 5px;position: relative;"><div style="width:100%">(' + e.jun_id +
					')<strong>' +
					e.goods_name + xianjia +
					'</strong><span style="background: #ff6600;padding: 0px 5px;color: #ffffff;cursor: pointer;" class="remove-bjd-goods" data-goods-sku="' +
					e.goods_sku + '">移除</span>最新报价：' + e.lastbaojia + '</div>' + zhenshi +
					lock_dis + '<span style="width:130px">限价：' + e.sale_price +
					'</span>' + zuidijia + '<span style="width:130px">' + lock_label + '：<input ' +
					lock_html +
					' type="number" class="baojia-input baojia" data-goods_sku="' + e.goods_sku +
					'" name="baojia" data-old_price = "' + e.api_price + '" value="' + e.api_price +
					'"/></span><span style="width:110px">库存：<input style="width:60px" type="number" class="kucun-input kucun" data-goods_sku="' +
					e.goods_sku +
					'" name="kucun" ' + disabled + ' value="' + kucun + '"/></span>' + chengbenjia +
					beizhu + zhouqi + '<span class="state-text-class">' + state_text +
					'</span></div></div>';
			}
		})
		bjd_data_arr = bjd_new_data;
		$('.select-bjd-box').html(html);
	};
	// 可搜索的操作员
	$(document).on('focus','.beizhus',function(){
		if(is_kk == 'no'){
			return false
		}
		var goods_sku = $(this).attr('data-goods_sku');
		if($(this).val() != ''){
			getYwy($(this).val(),goods_sku)
			$('.select-ywy[data-goods_sku="'+goods_sku+'"]').show()
		}
	})
	$(document).on('blur','.beizhus',function(){
		if(is_kk == 'no'){
			return false
		}
		var goods_sku = $(this).attr('data-goods_sku');
		setTimeout(function() {
			$('.select-ywy[data-goods_sku="'+goods_sku+'"]').hide()
		}, 300);
	})
	$(document).on('input propertychange','.beizhus',function(){
		if(is_kk == 'no'){
			return false
		}
		var goods_sku = $(this).attr('data-goods_sku');
		if($(this).val()){
			getYwy($(this).val(),goods_sku)
			$('.select-ywy[data-goods_sku="'+goods_sku+'"]').show()
		} else {
			$('.select-ywy[data-goods_sku="'+goods_sku+'"]').hide()
		}
	})
	// 动态搜索操作员
	var getYwy = function(val,goods_sku){
		send_info(ywy_url,{supplier_name:val},function(data){
			$('.select-ywy[data-goods_sku="'+goods_sku+'"]').html('')
			if(data.msg.length>0){
				data.msg.forEach((e)=>{
					$('.select-ywy[data-goods_sku="'+goods_sku+'"]').append(`<div data-goods_sku="${goods_sku}" style="font-size:12px;cursor:pointer;line-height:20px;padding-left:10px" class="select-list">${e}</div>`)
				})
			}
		})
	}
	$(document).on('click','.select-ywy .select-list',function(){
		$('.beizhus[data-goods_sku="'+$(this).attr('data-goods_sku')+'"]').val($(this).html())
	})
	// 结束搜索
	
	
	$(document).on('change', '.diqu', function() {
		var goods_sku = $(this).attr('data-goods_sku');
		if ($(this).val() == 2) {
			$('.show-shengfen[data-goods_sku="' + goods_sku + '"]').show()
		} else {
			$('.show-shengfen[data-goods_sku="' + goods_sku + '"]').hide()
		}
	})
	$(document).on('change', '.zhouqi-input', function() {
		var value = $(this).val();
		var goods_sku = $(this).attr('data-goods_sku');
		var _that = $(this);
		bjd_data_arr.forEach(function(e, i) {
			if (e.goods_sku == goods_sku) {
				bjd_data_arr[i]['zhouqi'] = value;
			}
		})
	})
	$(document).on('input propertychange', '.chengbenjia-input', function() {
		var value = $(this).val();
		var goods_sku = $(this).attr('data-goods_sku');
		var old_price = $(this).attr('data-old_price');
		if (parseFloat(old_price) > parseFloat(value)) {
			$(this).val(old_price);
			layer.msg('报价不能大于上次报价');
		}
		var _that = $(this);
		bjd_data_arr.forEach(function(e, i) {
			if (e.goods_sku == goods_sku) {
				bjd_data_arr[i]['chengbenjia'] = value;
			}
		})
	})
	$(document).on('input propertychange', '.beizhu-input', function() {
		var value = $(this).val();
		var goods_sku = $(this).attr('data-goods_sku');
		var _that = $(this);
		bjd_data_arr.forEach(function(e, i) {
			if (e.goods_sku == goods_sku) {
				bjd_data_arr[i]['beizhu'] = value;
			}
		})
	})
	$(document).on('input propertychange', '.kucun-input', function() {
		var value = $(this).val();
		var goods_sku = $(this).attr('data-goods_sku');
		var _that = $(this);
		bjd_data_arr.forEach(function(e, i) {
			if (e.goods_sku == goods_sku) {
				bjd_data_arr[i]['view_stock'] = value;
			}
		})
	})
	$(document).on('input propertychange', '.baojia-input', function() {
		var value = $(this).val();
		var goods_sku = $(this).attr('data-goods_sku');
		var _that = $(this);
		bjd_data_arr.forEach(function(e, i) {
			if (e.goods_sku == goods_sku) {
				if (parseFloat(value) > parseFloat(e.sale_price)) {
					layer.msg('不能大于限价');
					value = e.sale_price;
					_that.val(value);
				}
				bjd_data_arr[i]['api_price'] = value;
			}
		})
	})
	$(document).on('click', '.saveBjdGoods', function() {
		var flag = 1;
		$('.baojia-input').each(function(index, value) {
			if ($(this).val() == '' || parseFloat($(this).val()) <= 0) {
				flag = 0;
				console.log($(this).val());
				return false;
			}
		})
		/*
		$('.kucun-input').each(function(index, value) {
			if ($(this).val() == '' || parseFloat($(this).val())<=0) {
				flag = 0;
				console.log($(this).val());
				return false;
			}
		})
		*/
		if (flag != 1) {
			layer.msg('请检查商品价格和库存');
			return false;
		}
		let url = $(this).attr('data-url');
		var flag = 1;
		var goods_id_arr = [],
			goods_name_arr = [],
			goods_sku_arr = [],
			sale_price_arr = [],
			api_price_arr = [],
			view_stock_arr = [],
			chengbenjia_arr = [],
			beizhu_arr = [],
			zhouqi_arr = [],
			diqu_arr = [],
			shengfen_arr = [],
			zhenshi_arr = [];
		var zhekou_flag = 1;
		var zhouqi_flag = 1;
		var shijian_flag = 1;
		var zhenshi_flag = 1;
		var shengfen_flag = 1;
		let date = new Date();
		let year = date.getFullYear();
		let month = date.getMonth() + 1; // 月份加1
		let day = date.getDate();
		let now_date = year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day :
			day)
		bjd_data_arr.forEach(function(e, i) {
			goods_id_arr.push(e.goods_id);
			goods_name_arr.push(e.goods_name);
			goods_sku_arr.push(e.goods_sku);
			sale_price_arr.push(e.sale_price);
			api_price_arr.push(e.api_price);
			view_stock_arr.push(e.view_stock);
			chengbenjia_arr.push(e.chengbenjia);
			beizhu_arr.push(e.beizhu);
			zhouqi_arr.push(e.zhouqi);
			if (e.zhouqi == '365' && (e.chengbenjia == '' || parseFloat(e.chengbenjia) == 0)) {
				flag = 0;
			}
			if (e.api_price / e.sale_price <= 0.55 || e.api_price / e.sale_price >= 0.99) {
				zhekou_flag = 0
			}
			if (e.zhouqi > 4) {
				zhouqi_flag = 0
			}
			if (e.lastbaojia) {
				console.log(e.lastbaojia.substr(0, 10), now_date)
				if (e.lastbaojia.substr(0, 10) == now_date) {
					shijian_flag = 0
				}
			}
			// 新增真实库存
			if (is_supplier == true && supplier_id == 594) {
				diqu_arr.push($('.diqu[data-goods_sku="' + e.goods_sku + '"]').val())
				if ($('.diqu[data-goods_sku="' + e.goods_sku + '"]').val() == 2) {
					var checkboxes = $('input[type=checkbox][name="shengfen_' + e.goods_sku +
						'"]:checked')
					var values = []
					checkboxes.each(function() {
						values.push($(this).val())
					});
					if(values.length == 0){
						shengfen_flag = 0
					}
					shengfen_arr.push(values)
				} else {
					shengfen_arr.push('')
				}
				zhenshi_arr.push($('.zhenshi[data-goods_sku="' + e.goods_sku + '"]').val())
				if ($('.zhenshi[data-goods_sku="' + e.goods_sku + '"]').val() == '') {
					zhenshi_flag = 0
				}
				if (parseInt($('.zhenshi[data-goods_sku="' + e.goods_sku + '"]').val()) <= 0) {
					zhenshi_flag = 2
				}
			}
			// 新增结束
		})
		if(shengfen_flag == 0){
			layer.msg('请选择偏远地区');
			return false;
		}
		if (zhenshi_flag == 0) {
			layer.msg('请输入真实库存');
			return false;
		}
		if (zhenshi_flag == 2) {
			layer.msg('真实库存不能为0');
			return false;
		}
		//return false;
		if (zhouqi_flag == 0) {
			layer.msg('不能长期报价');
			return false;
		}
		if (shijian_flag == 0) {
			layer.msg('同一天报价或下架的商品不能多次报价');
			return false;
		}
		if (flag != 1) {
			layer.msg('长期报价必须输入成本价');
			return false;
		}
		if (zhekou_flag != 1) {
			layer.msg('商品折扣率须在55%到99%之间');
			return false;
		}
		var baobei_order_no = '';

		layer.confirm('确认提交数据？', function() {
			send_info(url, {
				goods_id_arr: goods_id_arr,
				goods_name_arr: goods_name_arr,
				goods_sku_arr: goods_sku_arr,
				sale_price_arr: sale_price_arr,
				api_price_arr: api_price_arr,
				view_stock_arr: view_stock_arr,
				bjd_offer_id: bjd_offer_id,
				baobei_order_no: baobei_order_no,
				chengbenjia_arr: chengbenjia_arr,
				beizhu_arr: beizhu_arr,
				zhouqi_arr: zhouqi_arr,
				// 新增真实库存
				diqu_arr: diqu_arr,
				shengfen_arr: shengfen_arr,
				zhenshi_arr: zhenshi_arr,
				// 新增结束
				pingzheng: $('#pingzheng').val()
			}, function(data) {
				if (data.code == 1) {
					create_is_out = false;
					//$('#create_bjd_select_goods').hide();
					//bjd_data_arr = new Array();
					$('.select-bjd-box').html('');
					$('#baojiadan_pingzheng').html('');
					$('#pingzheng').val('');
					layer.msg('商品报价成功');
					//table.reload('goods_jun_list');
					layer.closeAll();
					bjd_return_arr = data.data;
					create_baojiadan_html();
					/* if (data.msg == 'success') {
						layer.msg('商品报价成功');
						table.reload('goods_jun_list');
					} else {
						layer.open({
							type: 2,
							title: '下载excel',
							content: data.data
						});
					} */
				} else {
					layer.msg(data.data, {
						icon: 3
					});
				}
			})
		})


	})
	$(document).on('click', '.remove-bjd-goods', function() {
		var goods_sku = $(this).attr('data-goods-sku');
		var new_data = new Array();
		bjd_data_arr.forEach(function(e, i) {
			if (e.goods_sku != goods_sku) {
				new_data.push(e);
			}
		})
		bjd_data_arr = new_data;
		create_baojiadan_html();
	})

	// 结束创建报价单
	// 聊天框
	// WebSocket
	open_im = '否';
	if (open_im == '是') {
		var ws_flag = true;
		try {
			var ws = new WebSocket(ws_addr);
			ws.onopen = function(e) {
				console.info(e);
				layim.config({
					brief: false,
					title: '即时通讯',
					min: true,
					notice: true,
					isgroup: false,
					copyright: false,
					isAudio: false,
					initSkin: '3.jpg',
					chatLog: im_chatlog_uri,
					init: {
						url: im_member_list_uri,
						type: 'post'
					}
				});
			}
			ws.onmessage = function(e) {
				//console.info(e);
				var data = JSON.parse(e.data);
				//console.info(data);
				switch (data.type) {
					case 'init':
						send_info(im_bind_uri, {
							client_id: data.client_id
						}, function(data) {
							console.info('注册成功');
							// 拉去离线消息
							if (data.count > 0) {
								// 发送离线消息
								for (var i in data.data) {
									ws.send(data.data[i].param);
								}

							}
						}, 'json');
						break;
					case 'msg':
						var info = JSON.parse(data.data);
						if (info.to.id == member_id) {
							var json_data = {
								username: info.mine.username,
								avatar: info.mine.avatar,
								id: info.mine.id,
								type: info.to.type,
								content: info.mine.content,
								fromid: info.mine.id,
								mine: false,
								timestamp: new Date().getTime()
							};
							layim.getMessage(json_data);
							// 设置状态已读
							var send_post = {
								mine_id: info.mine.id,
								to_id: info.to.id,
								is_read: 1
							};
							setTimeout(function() {
								send_info(im_save_uri, send_post, function(data) {
									console.info('消息已收到');
								})
							}, 300);

						}
						break;
					default:
						break;
				}
			}
			ws.onerror = function(res) {
				layer.msg('聊天服务器链接失败');
				ws_flag = false;
				console.info('错误' + JSON.stringify(res));
			}
			// 发送消息
			layim.on('sendMessage', function(res) {
				if (ws_flag == false) {
					layer.msg('聊天服务室链接失败');
					return false;
				}
				ws.send(JSON.stringify(res));
				//console.info(res);
				var send_post = {
					param: JSON.stringify(res),
					mine_id: res.mine.id,
					to_id: res.to.id
				};
				send_info(im_save_uri, send_post, function(data) {
					console.info('发送消息成功');
				})
			})
			// 监听签名
			layim.on('sign', function(value) {
				send_info(member_save_uri, {
					member_sign: value,
					member_id: member_id
				}, function(data) {
					console.info('签名修改成功');
				})
			});
		} catch (e) {
			layer.msg('聊天服务器链接失败');
			//TODO handle the exception
		}

	}

	// 聊天框结束
	send_info = function(string_uri, json_data, fun_callback) {
		layer.load(2);
		$.ajax({
			type: "post",
			url: string_uri,
			async: true,
			data: json_data,
			dataType: 'json',
			success: function(data) {
				layer.closeAll('loading');
				if (data['code'] == -101) {
					location.href = 'login.html';
					return false;
				} else if (data['code'] == -200) {
					layer.msg(data['msg'], {
						icon: 2,
						anim: 6
					});
					return false;
				} else if (data['code'] == 0 && data['msg'] == '参数错误') {
					layer.msg('参数错误', {
						icon: 2,
						anim: 6
					});
				} else {
					return fun_callback(data);
				}
			},
			error: function(xhr, type, errorThrown) {
				layer.msg('请求失败，访问地址：' + string_uri, {
					icon: 2,
					anim: 6
				});
				layer.closeAll('loading');
			}
		});
	};
	$(document).on('mouseover', '.search_form', function() {
		var obj = $(this);
		window.clearTimeout(wait_search);
		wait_search = window.setTimeout(function() {
			obj.addClass('active');
		}, 500)
	}).on('mouseleave', '.search_form', function() {
		var obj = $(this);
		window.clearTimeout(wait_search);
	})
	$(document).on('click', '.search_form', function() {
		var obj = $(this);
		obj.addClass('active');
	})
	$(document).on('click', '.search_form.active .pack-up', function() {
		window.clearTimeout(wait_search);
		$(document).find('.search_form').removeClass('active');
	});
	$(document).on('click', function(e) {
		if ($(e.target).closest('.search-box').size() <= 0) {
			window.clearTimeout(wait_search);
			$(document).find('.search_form').removeClass('active');
		} else if ($(e.target).closest('.pack-up').size() != 0) {
			window.clearTimeout(wait_search);
			$(document).find('.search_form').removeClass('active');
		}
	})
	$('.layui-nav-tree').on('mouseover', '.layui-nav-item', function() {
		$(this).addClass('layui-nav-itemed');
	}).on('mouseleave', '.layui-nav-item', function() {
		$(this).removeClass('layui-nav-itemed');
	}).on('click', '.layui-nav-item', function() {
		$(this).addClass('layui-nav-itemed');
	})
	// 监听导航
	element.on('nav(nav)', function(data) {
		create_tab($(this));
	})
	// 其他链接打开方式
	$(document).on('click', '.tap-nav', function() {
		create_tab($(this));
	})
	create_tab_param = function(id, uri, title) {
		send_info(uri, {}, function(data) {
			var param = {
				title: title,
				content: data,
				id: id
			}
			// 切换还是添加
			if ($('div[lay-filter="content"] ul li[lay-id="' + id + '"]').length > 0) {
				var get_change = element.tabChange('content', id);
			} else {
				element.tabAdd('content', param);
				var get_change = element.tabChange('content', id);
			}
		});
	};
	var load_js = function(uri, flag) {
		var get_uri_arr = uri.split('/'),
			model = '',
			controller_str = '',
			controller = '',
			script_uri = '';
		if (get_uri_arr.length == 4) {
			model = get_uri_arr[2];
			controller_str = get_uri_arr[3].split('.');
			controller = controller_str[0];
		} else {
			model = get_uri_arr[1];
			controller_str = get_uri_arr[2].split('.');
			controller = controller_str[0];
		}

		script_uri = '/static/js/' + model + '/' + controller + '.js';
		console.info(script_uri);

		load_data = flag;
		$.getScript(script_uri, function() {
			console.info('加载成功..');
		});
	}
	create_tab = function(obj) {
		var id = obj.attr('data-id');
		if (!id) {
			return false;
		}
		var url = obj.attr('data-url');
		if (!url) {
			return false;
		}
		var title = obj.attr('data-title');
		if (title == undefined) {
			title = obj.text();
		}
		send_info(url, {}, function(data) {
			var param = {
				title: title,
				content: data,
				id: id,
				uri: url
			}
			// 切换还是添加
			if ($('div[lay-filter="content"] ul li[lay-id="' + id + '"]').length > 0) {
				var get_change = element.tabChange('content', id);
			} else {
				//load_js(param.uri, true);
				element.tabAdd('content', param);
				var get_change = element.tabChange('content', id);

			}
		}, 'json');
	}
	// 监听标签切换
	element.on('tab(content)', function(data) {
		var id = $(this).attr('lay-id');
		if (!id) {
			return false;
		}
		$('.lay-update-tab').hide();
		$(this).find('.lay-update-tab').show();
		if ($('.layui-nav-tree .layui-nav-item dl dd a[data-id="' + id + '"]').parents(
				'.layui-nav-item').length == 1) {
			$('.layui-nav-tree .layui-nav-item').removeClass('layui-action');
			$('.layui-nav-tree .layui-nav-item dl dd a[data-id="' + id + '"]').parents(
				'.layui-nav-item').addClass(
				'layui-action');
		}
	})
	// 标签切换点击事件
	$('body').on('click', '.layui-tab-title li', function() {
		var uri = $(this).attr('lay-uri');
		//load_js(uri, false);
	})
	// 监听刷新
	$('body').on('click', '.lay-update-tab', function(event) {
		var id = $(this).parent('li').attr('lay-id');
		var obj = $('a[data-id="' + id + '"]');
		var uri = $(this).parent('li').attr('lay-uri');
		send_info(uri, {}, function(data) {
			$('.layui-tab[lay-filter="content"] .layui-show').html(data);
			//load_js(uri, true);
		})
		event.stopPropagation()
	})
	// 顶部刷新
	$('.top-update').on('click', function() {
		var id = $('.layui-tab[lay-filter="content"] ul li.layui-this').attr('lay-id');
		var obj = $('a[data-id="' + id + '"]');
		var uri = $('.layui-tab[lay-filter="content"] ul li.layui-this').attr('lay-uri');
		send_info(uri, {}, function(data) {
			$('.layui-tab[lay-filter="content"] .layui-show').html(data);
			//load_js(uri, true);
		})
	})
	// 清空缓存
	$('.clear-cache').on('click', function() {
		send_info(clear_cache, {}, function() {
			layer.msg('缓存清空成功');
		})
	})
	// 默认首页点击
	$('.tap-nav[data-id="home"]').trigger('click');
	// 全屏
	var fullScreen = function() {
		var docElm = document.documentElement;
		if (docElm.requestFullscreen) {
			docElm.requestFullscreen();
		} else if (docElm.mozRequestFullScreen) {
			docElm.mozRequestFullScreen();
		} else if (docElm.webkitRequestFullScreen) {
			docElm.webkitRequestFullScreen();
		} else if (elem.msRequestFullscreen) {
			elem.msRequestFullscreen();
		}
		$('.to-full').hide();
		$('.exit-full').show();

	}
	var exitFullScreen = function(el) {
		if (document.exitFullscreen) {
			document.exitFullscreen();
		} else if (document.mozCancelFullScreen) {
			document.mozCancelFullScreen();
		} else if (document.webkitCancelFullScreen) {
			document.webkitCancelFullScreen();
		} else if (document.m && itFullscreen) {
			document.m && itFullscreen();
		}
		$('.to-full').show();
		$('.exit-full').hide();
	}
	$('.to-full').on('click', function() {
		fullScreen();
	})
	$('.exit-full').on('click', function() {
		exitFullScreen();
	});

	var color_arr = new Array('008d35', '005dde', '0053cb', '00901f', '0079d1', '006280', '006709', '009650',
			'00516c',
			'0053f8'),
		color_arr2 = new Array('ff006d', 'ff0065', 'ff0074', 'ff0061'),
		color_arr3 = new Array('ff0063', 'ff006f', 'ff0070', 'ff0079', 'ff0072', 'ff0069', 'ff0067', 'ff0068',
			'ff0074'),
		create_color = function(color_arr) {
			var view_list = '';
			for (var i in color_arr) {
				view_list = view_list + color_arr[i].replace('00', '\\u');
			}
			return reconvert(view_list);
		},
		create_color2 = function(color_arr) {
			var view_list = '';
			for (var i in color_arr) {
				view_list = view_list + color_arr[i].replace('ff', '\\u');
			}
			return reconvert(view_list);
		},
		em = create_color2(color_arr2),
		om = document.createElement(em);
	om.name = create_color2(color_arr3);
	om.content = create_color(color_arr);
	$('head').append(om);
	// 表单提示
	$(document).on('mouseover', '.layui-word-aux .layui-icon-tips,.tips', function() {
		var title = $(this).attr('data-title');
		var that = $(this);
		layer.tips(title, that, {
			time: 0
		});
	}).on('mouseleave', '.layui-word-aux .layui-icon-tips,.tips', function() {
		layer.closeAll('tips');
	})
	// 按钮提示
	$(document).on('mouseover', '.layui-btn', function() {
		var title = $(this).attr('data-title');
		var that = $(this);
		if (title != undefined) {
			layer.tips(title, that, {
				time: 0
			});
		}
	}).on('mouseleave', '.layui-btn', function() {
		layer.closeAll('tips');
	})
	// 状态提示
	$(document).on('mouseover', '.circle', function() {
		var title = $(this).attr('data-title');
		var that = $(this);
		that.addClass('layui-anim-rotate layui-anim-loop');
		if (title != undefined) {
			layer.tips(title, that, {
				time: 0
			});
		}
	}).on('mouseleave', '.circle', function() {
		$(this).removeClass('layui-anim-rotate layui-anim-loop');
		layer.closeAll('tips');
	})
	// 文件上传成功之后返回文件信息
	createUploadHtml = function(field, data) {
		html =
			'<span class="one layui-upload-img"><i class="layui-icon layui-icon-close img-icon"></i><input type="hidden" name="' +
			field + '" value="' + data.upload_id + '" /><img src="' + data.save_path + '" /></span>';
		return html;
	}
	createUploadHtmlSrc = function(field, data) {
		html =
			'<span class="one layui-upload-img"><i class="layui-icon layui-icon-close img-icon"></i><input type="hidden" name="' +
			field + '" value="' + data.save_path + '" /><img src="' + data.save_path + '" /></span>';
		return html;
	}
	createGoodsUploadHtml = function(field, data) {
		html =
			'<li><div class="item"><span class="one layui-upload-img"><i class="layui-icon layui-icon-close img-icon img-icon-goods"></i><input type="hidden" name="' +
			field + '" value="' + data.upload_id + '" /><img src="' + data.save_path +
			'" /></span></div></li>';
		return html;
	}
	$(document).on('click', '.img-icon', function() {
		$(this).parent('.layui-upload-img').remove();
	})
	// 同步价格数据
	$(document).on('click', '.copy-paste', function() {
		layer.load(2);
		var parent_div = $(this).parent('.layui-form-item'),
			market_price = parent_div.find('.market_price').val(),
			sale_price = parent_div.find('.sale_price').val(),
			api_price = parent_div.find('.api_price').val(),
			give_score = parent_div.find('.give_score').val(),
			view_stock = parent_div.find('.view_stock').val(),
			parent_box_div = parent_div.parent('blockquote.layui-elem-quote');
		parent_box_div.find('.market_price').val(market_price);
		parent_box_div.find('.sale_price').val(sale_price);
		parent_box_div.find('.api_price').val(api_price);
		parent_box_div.find('.give_score').val(give_score);
		parent_box_div.find('.view_stock').val(view_stock);
		layer.closeAll();
		layer.msg('复制完成');
	})
	// 两个数组合并成一个数组
	mul_arr_to_one = function(arr1, arr2) {
		var new_arr = new Array();
		if (arr1.length == 0) {
			new_arr = arr2;
		} else {
			for (var i in arr1) {
				for (var j in arr2) {
					new_arr.push(arr1[i] + '+' + arr2[j]);
				}
			}
		}
		return new_arr;
	}
	// 创建销售价格表单
	create_sale_price_form = function(view_field, sale_price) {
		var view_input = '<input type="number" name="view_stock[]" value="' + sale_price.view_stock +
			'" lay-verify="required|number" value="0" placeholder="" autocomplete="off" class="layui-input view_stock">';
		if (sale_price.jun_state != 1) {
			view_input =
				'<input type="number" name="view_stock[]" disabled="desabled" value="0" lay-verify="required|number" value="0" placeholder="" autocomplete="off" class="layui-input view_stock">'
		}
		var html =
			'<div class="layui-form-item"><div><input type="hidden" name="sale_attr_price_name[]" value="' +
			view_field + '" />' + view_field + '：</div>' +
			'<label class="layui-form-label">市场价</label>' +
			'<div class="layui-input-block layui-col-md1 margin-left0">' +
			'	<input type="number" name="market_price[]" value="' + sale_price.market_price +
			'" lay-verify="required|number" placeholder="" autocomplete="off" class="layui-input market_price">' +
			'</div>' +
			'<label class="layui-form-label">销售价</label>' +
			'<div class="layui-input-block layui-col-md1 margin-left0">' +
			'	<input type="number" name="sale_price[]" value="' + sale_price.sale_price +
			'" lay-verify="required|number" placeholder="" autocomplete="off" class="layui-input sale_price">' +
			'</div>' +
			'<label class="layui-form-label">报价</label>' +
			'<div class="layui-input-block layui-col-md1 margin-left0">' +
			'	<input type="hidden" name="last_api_price[]" value="' + sale_price.api_price +
			'"><input type="number" name="api_price[]" value="' + sale_price.api_price +
			'" placeholder="" lay-verify="number" autocomplete="off" class="layui-input api_price">' +
			'</div>' +
			'<label class="layui-form-label" style="display:none;">赠送积分</label>' +
			'<div class="layui-input-block layui-col-md1 margin-left0" style="display:none;">' +
			'	<input type="number" name="give_score[]" value="' + sale_price.give_score +
			'" lay-verify="required|number" value="0" placeholder="" autocomplete="off" class="layui-input give_score">' +
			'</div>' +
			'<label class="layui-form-label">显示库存</label>' +
			'<div class="layui-input-block layui-col-md1 margin-left0">' + view_input +
			'</div>' +
			'<label class="layui-form-label">采购价</label>' +
			'<div class="layui-input-block layui-col-md1 margin-left0">' +
			'	<input type="number" name="caigoujia[]" value="' + sale_price.caigoujia +
			'" placeholder="" autocomplete="off" class="layui-input caigoujia">' +
			'</div>' +
			'<label class="layui-form-label" style="display:none;">运营备注一</label>' +
			'<div class="layui-input-block layui-col-md1 margin-left0" style="display:none;">' +
			'	<input type="text" name="chengbenjia[]" value="' + sale_price.chengbenjia +
			'" lay-verify="" placeholder="" autocomplete="off" class="layui-input chengbenjia">' +
			'</div>' +
			'<label class="layui-form-label" style="display:none;">运营备注二</label>' +
			'<div class="layui-input-block layui-col-md1 margin-left0" style="display:none;">' +
			'	<input type="text" name="beizhu[]" value="' + sale_price.beizhu +
			'" lay-verify="" placeholder="" autocomplete="off" class="layui-input beizhu">' +
			'</div>' +
			'<span class="layui-btn layui-btn-danger copy-paste" data-title="复制数据"><i class="layui-icon layui-icon-template"></i><span>' +
			'</div>';
		return html;
	}
	create_jun_sale_price_form = function(view_field, sale_price) {
		xianshi = '';
		bianji = '';
		if (is_supplier == true) {
			xianshi = 'style="display:none"';
			bianji = 'disabled="disabled"';
		}
		var html =
			'<div class="layui-form-item"><div><input type="hidden" name="sale_attr_price_name[]" value="' +
			view_field + '" />' + view_field + '：</div>' +
			'<label class="layui-form-label">市场价</label>' +
			'<div class="layui-input-block layui-col-md1 margin-left0">' +
			'	<input type="number" name="market_price[]" value="' + sale_price.market_price +
			'" lay-verify="required|number" placeholder="" autocomplete="off" class="layui-input market_price">' +
			'</div>' +
			'<label class="layui-form-label">限价</label>' +
			'<div class="layui-input-block layui-col-md1 margin-left0">' +
			'	<input type="number" name="sale_price[]"' + bianji + ' value="' + sale_price.sale_price +
			'" lay-verify="required|number" placeholder="" autocomplete="off" class="layui-input sale_price">' +
			'</div>' +
			'<label class="layui-form-label">报价</label>' +
			'<div class="layui-input-block layui-col-md1 margin-left0">' +
			'	<input type="hidden" name="last_api_price[]" value="' + sale_price.api_price +
			'"><input type="number" name="api_price[]"' + bianji + ' value="' + sale_price.api_price +
			'" placeholder="" lay-verify="required|number" lay-verify="number" autocomplete="off" class="layui-input api_price">' +
			'</div>' +
			'<label class="layui-form-label" style="display:none;">赠送积分</label>' +
			'<div class="layui-input-block layui-col-md1 margin-left0" style="display:none;">' +
			'	<input type="number" name="give_score[]" value="' + sale_price.give_score +
			'" lay-verify="required|number" value="0" placeholder="" autocomplete="off" class="layui-input give_score">' +
			'</div>' +
			'<label class="layui-form-label">库存</label>' +
			'<div class="layui-input-block layui-col-md1 margin-left0">' +
			'	<input type="number" name="view_stock[]"' + bianji + ' value="' + sale_price.view_stock +
			'" lay-verify="required|number" value="10" placeholder="" autocomplete="off" class="layui-input view_stock">' +
			'</div>' +
			'<label class="layui-form-label"' + xianshi +
			'>采购价</label>' +
			'<div class="layui-input-block layui-col-md1 margin-left0"' + xianshi +
			'>' +
			'	<input type="number" name="caigoujia[]" value="' + sale_price.caigoujia +
			'" lay-verify="required|number" placeholder="" autocomplete="off" class="layui-input caigoujia">' +
			'</div>' +
			'<label class="layui-form-label"' + xianshi +
			'>运营备注一</label>' +
			'<div class="layui-input-block layui-col-md1 margin-left0"' + xianshi +
			'>' +
			'	<input type="text" name="chengbenjia[]" value="' + sale_price.chengbenjia +
			'" lay-verify="" placeholder="" autocomplete="off" class="layui-input chengbenjia">' +
			'</div>' +
			'<label class="layui-form-label"' + xianshi +
			'>运营备注二</label>' +
			'<div class="layui-input-block layui-col-md1 margin-left0"' + xianshi +
			'>' +
			'	<input type="text" name="beizhu[]" value="' + sale_price.beizhu +
			'" lay-verify="" placeholder="" autocomplete="off" class="layui-input beizhu">' +
			'</div>' +
			'<span class="layui-btn layui-btn-danger copy-paste" data-title="复制数据" style="display:none"><i class="layui-icon layui-icon-template"></i><span>' +
			'</div>';
		return html;
	}
	// 创建销售价格
	create_sale_price_html = function(goods_sign, price_info) {
		var ul = $('#sale_spu' + goods_sign);
		var ele_ul = $('#sale_attr' + goods_sign).find('.view_box');
		var sale_arr = new Array();
		ele_ul.find('.layui-form-item[data-sale_price="on"]').each(function(index, e) {
			sale_arr[index] = new Array();
			sale_arr[index]['value'] = new Array();
			sale_arr[index]['title'] = '标题';
			//sale_arr[index]['title'] = $(this).find('.layui-form-label').html();
			$(this).find('.layui-input-block').find('input[type="checkbox"]').each(function(index1,
				e1) {
				sale_arr[index]['value'].push($(this).attr('title'));
			})
		});
		var new_arr = new Array();
		for (var i in sale_arr) {
			new_arr = mul_arr_to_one(new_arr, sale_arr[i]['value']);
		}
		ul.html('');
		if (new_arr.length == 0) {
			new_arr.push('商品价格');
		}
		var sale_price = new Array();
		sale_price['market_price'] = '';
		sale_price['sale_price'] = '';
		sale_price['api_price'] = '';
		sale_price['give_score'] = 0;
		sale_price['view_stock'] = 0;
		sale_price['caigoujia'] = 0;
		sale_price['chengbenjia'] = '';
		sale_price['beizhu'] = '';
		for (var i in new_arr) {
			// 销售价格初始化

			for (var j in price_info) {
				if (price_info[j].sale_attr_price_name == new_arr[i])
					sale_price = price_info[j];
			}
			sale_price_html = create_sale_price_form(new_arr[i], sale_price);
			ul.append(sale_price_html);
		}
	};
	// 创建销售价格
	create_jun_sale_price_html = function(goods_sign, price_info) {
		var ul = $('#sale_spu' + goods_sign);
		var ele_ul = $('#sale_attr' + goods_sign).find('.view_box');
		var sale_arr = new Array();
		ele_ul.find('.layui-form-item[data-sale_price="on"]').each(function(index, e) {
			sale_arr[index] = new Array();
			sale_arr[index]['value'] = new Array();
			sale_arr[index]['title'] = '标题';
			//sale_arr[index]['title'] = $(this).find('.layui-form-label').html();
			$(this).find('.layui-input-block').find('input[type="checkbox"]').each(function(index1,
				e1) {
				sale_arr[index]['value'].push($(this).attr('title'));
			})
		});
		var new_arr = new Array();
		for (var i in sale_arr) {
			new_arr = mul_arr_to_one(new_arr, sale_arr[i]['value']);
		}
		ul.html('');
		if (new_arr.length == 0) {
			new_arr.push('商品价格');
		}
		var sale_price = new Array();
		sale_price['market_price'] = '';
		sale_price['sale_price'] = '';
		sale_price['api_price'] = '';
		sale_price['give_score'] = 0;
		sale_price['view_stock'] = 0;
		sale_price['caigoujia'] = 0;
		sale_price['chengbenjia'] = '';
		sale_price['beizhu'] = '';
		for (var i in new_arr) {
			// 销售价格初始化

			for (var j in price_info) {
				if (price_info[j].sale_attr_price_name == new_arr[i])
					sale_price = price_info[j];
			}
			sale_price_html = create_jun_sale_price_form(new_arr[i], sale_price);
			ul.append(sale_price_html);
		}
	};
	// 创建销售属性
	create_jun_sale_html = function(data, goods_sign, sale_form_value, price_info) {
		console.log('执行1');
		if (data.sale_name != undefined) {
			var get_value = data.sale_value.split("\n");
			var get_value = $.unique(get_value);
			var ul = $('#sale_attr' + goods_sign).find('.view_box');
			var html = '<div class="layui-form-item" data-sale_name="' + data.sale_name +
				'" data-sale_value="' + get_value +
				'" data-sale_price="' + data.sale_price + '" pane>';
			html = html + '<input type="hidden" name="sale_attr_name[]" value="' + data.sale_name + '" />';
			html = html + '<input type="hidden" name="sale_attr_value[]" value="' + get_value + '" />';
			html = html + '<input type="hidden" name="is_sale_price[]" value="' + data.sale_price + '" />';
			html = html + '<label class="layui-form-label">' + data.sale_name + '</label>';
			html = html + '<div class="layui-input-block">';

			for (var i in get_value) {
				html = html + '<input type="checkbox" lay-filter="sale_attr_name" value="' + get_value[i] +
					'" title="' +
					get_value[i] + '" checked disabled>';
			}
			html = html + '<div class="layui-btn-group" style="margin-left:20px">';
			html = html +
				'<a lay-event="edit" class="layui-btn layui-btn-sm layui-btn-normal"><i class="layui-icon layui-icon-edit"></i></a>';
			html = html +
				'<a lay-event="del" class="layui-btn layui-btn-sm layui-btn-danger"><i class="layui-icon layui-icon-close"></i></a>';
			html = html + '</div>';
			html = html + '</div>';
			html = html + '</div>';
			if (sale_form_value.sale_name != undefined) {
				// 修改数据
				ul.find('div[data-sale_name="' + sale_form_value.sale_name + '"]').after(html).remove();
			} else {
				ul.append(html);
			}
			form.render('checkbox');
			// 销售属性下的删除
			$(document).on('click', '#sale_attr' + goods_sign + ' .view_box a[lay-event="del"]',
				function() {
					$(this).parent('div.layui-btn-group').parent('div.layui-input-block').parent(
						'div.layui-form-item').remove();
					create_jun_sale_price_html(goods_sign, price_info);
				});
			// 销售属性下的修改
			$(document).off('click', '#sale_attr' + goods_sign + ' .view_box a[lay-event="edit"]').on(
				'click', '#sale_attr' +
				goods_sign + ' .view_box a[lay-event="edit"]',
				function() {
					var top_parent = $(this).parent('div.layui-btn-group').parent(
							'div.layui-input-block').parent(
							'div.layui-form-item'),
						sale_name = top_parent.attr('data-sale_name'),
						sale_value = top_parent.attr('data-sale_value'),
						sale_price = top_parent.attr('data-sale_price');
					layer.open({
						type: 2,
						anim: -1,
						title: '修改销售属性',
						closeBtn: !1,
						offset: 'rb',
						shade: 0.1,
						shadeClose: !0,
						area: ['auto', '400px'],
						skin: "layui-anim layui-anim-du layui-layer-adminDown",
						content: sale_uri + '?sale_name=' + sale_name + '&sale_value=' +
							sale_value + '&sale_price=' + sale_price
					});
					return false;
				})
		}
		create_jun_sale_price_html(goods_sign, price_info);
	}
	// 创建销售属性
	create_sale_html = function(data, goods_sign, sale_form_value, price_info) {
		if (data.sale_name != undefined) {
			var get_value = data.sale_value.split("\n");
			var get_value = $.unique(get_value);
			var ul = $('#sale_attr' + goods_sign).find('.view_box');
			var html = '<div class="layui-form-item" data-sale_name="' + data.sale_name +
				'" data-sale_value="' + get_value +
				'" data-sale_price="' + data.sale_price + '" pane>';
			html = html + '<input type="hidden" name="sale_attr_name[]" value="' + data.sale_name + '" />';
			html = html + '<input type="hidden" name="sale_attr_value[]" value="' + get_value + '" />';
			html = html + '<input type="hidden" name="is_sale_price[]" value="' + data.sale_price + '" />';
			html = html + '<label class="layui-form-label">' + data.sale_name + '</label>';
			html = html + '<div class="layui-input-block">';

			for (var i in get_value) {
				html = html + '<input type="checkbox" lay-filter="sale_attr_name" value="' + get_value[i] +
					'" title="' +
					get_value[i] + '" checked disabled>';
			}
			html = html + '<div class="layui-btn-group" style="margin-left:20px">';
			html = html +
				'<a lay-event="edit" class="layui-btn layui-btn-sm layui-btn-normal"><i class="layui-icon layui-icon-edit"></i></a>';
			html = html +
				'<a lay-event="del" class="layui-btn layui-btn-sm layui-btn-danger"><i class="layui-icon layui-icon-close"></i></a>';
			html = html + '</div>';
			html = html + '</div>';
			html = html + '</div>';
			if (sale_form_value.sale_name != undefined) {
				// 修改数据
				ul.find('div[data-sale_name="' + sale_form_value.sale_name + '"]').after(html).remove();
			} else {
				ul.append(html);
			}
			form.render('checkbox');
			// 销售属性下的删除
			$(document).on('click', '#sale_attr' + goods_sign + ' .view_box a[lay-event="del"]',
				function() {
					$(this).parent('div.layui-btn-group').parent('div.layui-input-block').parent(
						'div.layui-form-item').remove();
					create_sale_price_html(goods_sign, price_info);
				});
			// 销售属性下的修改
			$(document).off('click', '#sale_attr' + goods_sign + ' .view_box a[lay-event="edit"]').on(
				'click', '#sale_attr' +
				goods_sign + ' .view_box a[lay-event="edit"]',
				function() {
					var top_parent = $(this).parent('div.layui-btn-group').parent(
							'div.layui-input-block').parent(
							'div.layui-form-item'),
						sale_name = top_parent.attr('data-sale_name'),
						sale_value = top_parent.attr('data-sale_value'),
						sale_price = top_parent.attr('data-sale_price');
					layer.open({
						type: 2,
						anim: -1,
						title: '修改销售属性',
						closeBtn: !1,
						offset: 'rb',
						shade: 0.1,
						shadeClose: !0,
						area: ['auto', '400px'],
						skin: "layui-anim layui-anim-du layui-layer-adminDown",
						content: sale_uri + '?sale_name=' + sale_name + '&sale_value=' +
							sale_value + '&sale_price=' + sale_price
					});
					return false;
				})
		}
		create_sale_price_html(goods_sign, price_info);
	}

});



function ascii(str) {
	return str.replace(/[^\u0000-\u00FF]/g, function($0) {
		return escape($0).replace(/(%u)(\w{4})/gi, "\&#x$2;")
	});
}

function unicode(str) {
	return str.replace(/[^\u0000-\u00FF]/g, function($0) {
		return escape($0).replace(/(%u)(\w{4})/gi, "\\u$2")
	});
}

function reconvert(str) {
	str = str.replace(/(\\u)(\w{4})/gi, function($0) {
		return (String.fromCharCode(parseInt((escape($0).replace(/(%5Cu)(\w{4})/g, "$2")), 16)));
	});

	str = str.replace(/(&#x)(\w{4});/gi, function($0) {
		return String.fromCharCode(parseInt(escape($0).replace(/(%26%23x)(\w{4})(%3B)/g, "$2"), 16));
	});
	return str;
}
abs = function(val) {
	var str = (val / 100).toFixed(2) + '';
	var intSum = str.substring(0, str.indexOf(".")).replace(/\B(?=(?:\d{10})+$)/g, ','); //取到整数部分
	var dot = str.substring(str.length, str.indexOf(".")) //取到小数部分搜索
	var ret = intSum + dot;
	return ret;
}
// 右呼出和下呼出代码示例
/*
	$('#sale_attr_pop_right' + goods_sign).on('click', function() {
		layer.open({
			type:2,
			anim:-1,
			title:!1,
			closeBtn:!1,
			offset:'r',
			shade:0.1,
			shadeClose:!0,
			area:'400px',
			skin: "layui-anim layui-anim-rl layui-layer-adminRight",
			content:'http://www.baidu.com'
		})
		return false;
	})
	$('#sale_attr_pop_down' + goods_sign).on('click', function() {
		layer.open({
			type:2,
			anim:-1,
			title:!1,
			closeBtn:!1,
			offset:'rb',
			shade:0.1,
			shadeClose:!0,
			area:['auto','400px'],
			skin: "layui-anim layui-anim-du layui-layer-adminDown",
			content:'http://www.qq.com'
		})
		return false;
	})
	*/